import { request } from '@/utils/request'
import type {
  additionalProperties1,
  arrs1,
  obj1,
  obj2,
  arrss1,
  arrss2
} from './types/Applic'
//应用分页列表
type ying = {
  category?: string
  name?: string
  theme?: string
}
export const getApps = (params: ying) =>
  request<additionalProperties1>('/api/h5/application/list', 'get', params)
//应用字母分类

export const getAppsByLetter = (params: ying) =>
  request<any>('/api/h5/application/group/list', 'get', params)
//线上单点登录接口
export const ssoLogin = (params: any) =>
  request<obj1>('/redirectLogin', 'get', params)
//本地获取token接口
export const localLogin = () => request<obj2>('/test/redirectLogin', 'get')
//资讯中心
type pars = {
  startTime?: string
  endTime?: string
  page?: number
  pageSize?: number
  title?: string
  typeId?: number
}
export const getNews = (params: pars) =>
  request<arrs1>('/api/news/page', 'get', params)
//资讯分类
export const getTypeList = () => request<arrss1>('/api/news/type/list', 'GET')

//应用主题类别列表
export const getThemeList = (type: number) =>
  request<arrss1>(`/api/app/type/list/${type}`, 'GET')

//应用评价保存
type saveAppComment = {
  appId: string
  fraction: string
}
export const saveAppComment = (data: saveAppComment) =>
  request<any>('/api/evaluation/save', 'POST', data)
//新增收藏接口
type addCollect = {
  appId: string
  appIds: Array<string>
}
export const addCollect = (data: addCollect) =>
  request<any>('/api/h5/app/collection/add', 'POST', data)
//保存收藏列表
type delCollect = {
  data: boolean
}
export const saveCollect = (data: addCollect) => {
  return request<delCollect>('/api/h5/app/collection/save', 'POST', data)
}

//常用应用
export const getCommonlyUsed = (params: any) =>
  request<additionalProperties1>(
    '/api/h5/application/record/list',
    'GET',
    params
  )
//主题类别的应用数量统计列表
export const getThemeAppCount = () =>
  request<arrss2>('/api/app/type/count/list', 'GET')
